package com.hdax.dm.service;

import com.hdax.dm.entity.scheduler.Scheduler;
import com.hdax.dm.feign.scheduler.SchedulerFeign;
import com.hdax.dm.vo.TimePlanVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SchedulerService {

    @Autowired
    private SchedulerFeign schedulerFeign;

    public List<TimePlanVo> getTimePlan(Long itemId){
        List<Scheduler> schedulers = schedulerFeign.timePlan(itemId);
        List<TimePlanVo> timePlans = new ArrayList<>();
        schedulers.forEach(scheduler -> {
            TimePlanVo timePlan = new TimePlanVo();
            BeanUtils.copyProperties(scheduler,timePlan);
            timePlans.add(timePlan);
        });
        return timePlans;
    }

}
